<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.sz.common.ICommonDAO" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String business_id = request.getParameter("business_id");
String src = "page/business_summary.jsp?business_id=" + business_id;
String style1 = "width: 80;text-align:right;font-size: 12px;";
String style2 = "width: 120px";
String style3 = "color: red;text-align:left;";
String style4 = "font-size: 12px;";
//菜系
StringBuffer buf = new StringBuffer();
ServletContext servletContext = request.getSession().getServletContext(); 
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
ICommonDAO dao2 = (ICommonDAO) context.getBean("CommonDAO");
buf.delete(0, buf.length());
buf.append("select serial_id, name from course_serial where serial_level = 1 order by display_order");
List serial_list = dao2.queryForList(buf.toString());
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<link href="<%= request.getContextPath() %>/css/main.css" rel="stylesheet" type="text/css" />		
		<base href="<%=basePath%>" target="_self">
		<title>新增菜系</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="addTicket">
		<meta http-equiv="description" content="新增菜系">
	</head>
	
	<body>
		<script type="text/javascript" src="js/calendar.js"></script>
		<script type="text/javascript" src="js/utility.js"></script>	
		
	  	<form name="addCourseSerial_form"  action="courseserial/addCourseSerial2.exec" method="post" onsubmit=""> 
  	 <table width="100%" border="0" >
	  	 
	   	<tr>
		  	<td style="<%=style1%>" align="center">上级菜系名称</td>
		  	<td>
		  	      <select id="sj" name="sj" style="<%=style2%>">
			  		<%
		  			String value;
		  		 	String text;
					 for(int i = 0; i < serial_list.size(); ++i) {
						Map map = (Map)serial_list.get(i);
						value = map.get("SERIAL_ID").toString();
						text = map.get("NAME").toString();												
					 %>
					  <option value="<%=value%>"> 
					  <%=text%> 
					  </option>
					 <%} %> 
		  	      </select>
		  	</td>
		  	
	  	</tr>
  		<tr>
		  	<td style="<%=style1%>" align="center">菜系名称</td>
		  	<td>
		  		<input type="text" id="name" name="name" style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	
	  	</tr>
	  	<tr>
		  	<td style="<%=style1%>">菜系描述</td>
		  	<td>
		  		<input type="text" id="descrip" name="descrip" style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>
	  	</tr>
		<tr>
	  		<td  align="center">
		  		<input type="submit" value="添加" style="width: 80px;height: 40px;">
		  	</td>
		</tr>
	  	</table>
	  	
	  	<br/> 	
	  
	  	
	  	
  	</form>
	
  	
  	<SCRIPT LANGUAGE="JavaScript">
  		function onClickRadio_sex(id) {
  			if(id == 'sex_male') {
 				document.getElementById("sex_male").checked = true;
 				document.getElementById("sex_female").checked = false;
 				document.getElementById("sex_unknown").checked = false;
 			} else if(id == 'sex_female'){
 				document.getElementById("sex_female").checked = true;
 				document.getElementById("sex_male").checked = false; 				
 				document.getElementById("sex_unknown").checked = false;
 			} else {
 				document.getElementById("sex_unknown").checked = true;
 				document.getElementById("sex_female").checked = false;
 				document.getElementById("sex_male").checked = false; 				
 				
 			}
  		}
  		function onClickRadio_position(id) {
  			if(id == 'position_room') {
 				document.getElementById("position_room").checked = true;
 				document.getElementById("position_mall").checked = false;
 				document.getElementById("position_any").checked = false;
 			} else if(id == 'position_mall'){
 				document.getElementById("position_mall").checked = true;
 				document.getElementById("position_room").checked = false;
 				document.getElementById("position_any").checked = false;
 			} else {
 				document.getElementById("position_any").checked = true;
 				document.getElementById("position_mall").checked = false;
 				document.getElementById("position_room").checked = false;
 			}
  		}
  		function check() {
  	  		
  			var tmp;
			
  			tmp = document.getElementById("cust_tel").value;
  			if(IsPhone(tmp)==false) {
  	  			alert("请输入正确的客户电话号码,可以包括()、- 字符");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("cust_name").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请输入客户姓名");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("business_id").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请选择商家");
  	  			return false;
  			}

  			//预约时间
  			tmp = document.getElementById("demand_time_d").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请预约时间");
  	  			return false;
  			}
  			tmp = document.getElementById("demand_time_t").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请预约时间");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("demand_num").value;
  			if(IsInteger(tmp)==false) {
  	  			alert("请正确输入预约桌数，只能为数字");
  	  			return false;
  			}
  			  
  			tmp = document.getElementById("staff_num").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请填写用餐人数");
  	  			return false;
  			}
  			
  			if(document.getElementById("sex_male").checked == true) {
  				document.getElementById("cust_sex").value = 1;
  			} else if(document.getElementById("sex_female").checked == true) {
  				document.getElementById("cust_sex").value = 0;
  			} else {
  				document.getElementById("cust_sex").value = -1;
  			}
  			
  			if(document.getElementById("position_room").checked == true) {
  				document.getElementById("position_flag").value = 2;
  			} else if(document.getElementById("position_mall").checked == true) {
  				document.getElementById("position_flag").value = 1;
  			} else if(document.getElementById("position_any").checked == true) {
  				document.getElementById("position_flag").value = 0;
  			} else {
  				alert("请选择用餐环境");
  				return false;
  			}
  			
  			if(document.getElementById("notice_phone").checked == true &&
  				document.getElementById("notice_sms").checked == true) {
  				document.getElementById("notice_flag").value = 3;
  			} else if(document.getElementById("notice_phone").checked == true) {
  				document.getElementById("notice_flag").value = 1;
  			} else if(document.getElementById("notice_sms").checked == true) {
  				document.getElementById("notice_flag").value = 2;
  			} else {
  				alert("请选择通知方式");
  				return false;
  			}
  			
  			if(document.getElementById("window").checked == true) {
  				document.getElementById("window_flag").value = 1;
  			} else {
  				document.getElementById("window_flag").value = "";
  			} 
  			
  			if(document.getElementById("nosmoking").checked == true) {
  				document.getElementById("nosmoking_flag").value = 1;
  			} else {
  				document.getElementById("nosmoking_flag").value = "";
  			}
  			
  			if(document.getElementById("baby").checked == true) {
  				document.getElementById("baby_flag").value = 1;
  			} else {
  				document.getElementById("baby_flag").value = "";
  			}
  			
  			if(document.getElementById("wc").checked == true) {
  				document.getElementById("wc_flag").value = 1;
  			} else {
  				document.getElementById("wc_flag").value = "";
  			}
  			
  			if(document.getElementById("hurry").checked == true) {
  				document.getElementById("hurry_flag").value = 1;
  			} else {
  				document.getElementById("hurry_flag").value = "";
  			}
  			
  			return true;
  			
  		}
  	
  		function onClick_AutoLock() {
  			if(document.getElementById("checkbox_autolock").checked == true) {
  				document.getElementById("set_lockmanager_null").value = "";
  			} else {
  				document.getElementById("set_lockmanager_null").value = "1";
  			} 
  		}
  	</SCRIPT>
	</body>
</html>
